package com.fulihui.common.error;

/**
 * @author: Levon
 * @version: v 0.1 2018-06-06 16:49
 */
public class Errors {

    public enum Commons implements ServiceError {

        SYSTEM_ERROR(100, "系统异常"),
        REQUEST_PARAMETER_ERROR(101, "请求参数错误"),
        RECORD_ALREADY_EXISTS(102, "记录已存在"),
        RECORD_NOT_EXISTS(103, "记录不存在"),
        SAVE_FAILED(104, "保存失败"),
        UPDATE_FAILED(105, "更新失败"),
        DELETE_FAILED(106, "删除失败"),
        UPLOAD_FAIL(107, "上传文件失败"),
        TOKEN_DOES_NOT_EXIST(108, "公众号token不存在"),
        ID_CANNOT_BE_NULL(109, "主键ID不能为空"),
        UNKNOWN_ERROR(110, "系统异常");

        int errcode;
        String errmsg;

        Commons(int errcode, String errmsg) {
            this.errcode = errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    public enum UserLoginError implements ServiceError {

        USER_REGISTRATION_FAILED(1002, "用户注册失败"),
        OLD_PASSWORD_INCORRECTLY(1003, "原密码输入错误"),
        CHANGE_PASSWORD_FAILED(1004, "修改密码失败"),
        USER_AND_PASSWORD_NOT_MATCH(1005, "用户名和密码不匹配"),
        CONFIRM_PASSWORD_FAILED(1007, "两次密码不一致"),
        NEWPASSWORD_SAME_AS_OLDPASSWORD(1008, "新密码与旧密码相同");

        int errcode;
        String errmsg;

        UserLoginError(int errcode, String errmsg) {
            this.errcode = errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    public enum WxSystemConfigError implements ServiceError {

        REFRESH_FAILED(2003, "刷新失败"),
        COMPONENT_ACCESS_TOKEN_EXPIRED(2004, "component_access_token已经过期"),
        GET_TOKEN_FAILED(2005, "access_token获取失败");

        int errcode;
        String errmsg;

        WxSystemConfigError(int errcode, String errmsg) {
            this.errcode = errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    public enum UserLoginWxError implements ServiceError {

        BIND_FAILED(4001, "绑定失败");

        int errcode;
        String errmsg;

        UserLoginWxError(int errcode, String errmsg) {
            this.errcode = errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    public enum WxSevenRetentionError implements ServiceError {

        RECORD_ALREADY_EXISTS(5003, "当前公众号该日期记录已存在");

        int errcode;
        String errmsg;

        WxSevenRetentionError(int errcode, String errmsg) {
            this.errcode = errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    public enum WxSubscribeReplyError implements ServiceError {

        RECORD_ALREADY_EXISTS(6001, "当前公众号默认回复规则已存在"),
        ID_AND_SCENESTR_CANNOT_BE_ALL_EMPTY(6002, "id和sceneStr不能同时为空"),
        NOT_EXIST(6003, "该回复规则不存在");


        int errcode;
        String errmsg;

        WxSubscribeReplyError(int errcode, String errmsg) {
            this.errcode = errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    public enum WxParamQrcodeError implements ServiceError {

        WECHAT_QR_CODE_FAILED(7001, "调用微信生成渠道二维码失败"),
        WECHAT_QR_CODE_ID_ALREADY_EXISTS(7002, "渠道二维码唯一标识已存在");

        int errcode;
        String errmsg;

        WxParamQrcodeError(int errcode, String errmsg) {
            this.errcode = errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    public enum Wx48HError implements ServiceError {

        WX48_HOURS_MESSAGE_NOT_FOUND(8001, "未查询到48小时图文消息"),
        THE_CURRENT_APP_PUSHES_RECORD_EMPTY(8002, "当前公众号符合推送人数为0"),
        CANNOT_CANCEL_NOT_AWAIT_LOG(8003, "不允许取消非等待发送中任务");

        int errcode;
        String errmsg;

        Wx48HError(int errcode, String errmsg) {
            this.errcode = errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    public enum WxTemplateError implements ServiceError {

        CANNOT_DELETE_VALID_TEMPLATE(9001, "当前模板有效，不允许删除！"),
        PRIMARY_KEY_AND_TEMPLATE_ID_CANNOT_ALL_EMPTY(9002, "主键和模板ID不能同时为空！"),
        THIS_TEMPLATE_IS_NOT_VALID(9003, "当前模板已无效！");

        int errcode;
        String errmsg;

        WxTemplateError(int errcode, String errmsg) {
            this.errcode = errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    public enum WxTemplateLogError implements ServiceError {

        CANNOT_CANCEL_NOT_PUSHING_OR_AWAIT_LOG(10001, "不是等待或者发送中的任务不允许取消！"),
        CANNOT_EDIT_NOT_JOB_LOG(10005, "不是定时的模板发送任务不允许修改！"),
        THE_CURRENT_APP_PUSHES_RECORD_EMPTY(10002, "当前公众号符合推送人数为0"),
        ID_CANNOT_BE_EMPTY(10003, "批次ID不能为空"),
        TEMPLATE_LOG_RECORD_INSERT_ERROR(10004, "发送消息记录插入失败");

        int errcode;
        String errmsg;

        WxTemplateLogError(int errcode, String errmsg) {
            this.errcode = errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    public enum WxMaterialError implements ServiceError {

        MATERIAL_HAS_EXPIRED(1, "图文素材已失效！"),
        MATERIAL_LOCAL_IS_NOT_FOUND(2, "图文素材本地未找到！");

        int errcode;
        String errmsg;

        WxMaterialError(int errcode, String errmsg) {
            this.errcode = errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    public enum MassError implements ServiceError {

        NO_JOB_LOG_CANNOT_CANCEL(1, "非定时任务不能取消！");

        int errcode;
        String errmsg;

        MassError(int errcode, String errmsg) {
            this.errcode = errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }
}
